package com.yswy.common.serializer;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

public class CustomDateDeserializer extends JsonDeserializer<LocalDate> {
	@SuppressWarnings("unused")
	private static Logger log = LoggerFactory.getLogger(CustomDateDeserializer.class);
	
    @Override  
    public LocalDate deserialize(JsonParser jp, DeserializationContext ctxt)
            throws IOException, JsonProcessingException {
    	
        return LocalDate.parse(jp.getText(), DateTimeFormat.forPattern("yyyy-MM-dd"));
    }  
} 